﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibraryO2S;
using System.Data;
using System.Xml;

public partial class Administrator_DetailtEvent : System.Web.UI.Page
{
    Dataprocess data = new Dataprocess();
    string pathimg = "";
    
    protected void Page_Load(object sender, EventArgs e)
    {
        string ht = ReadServer();
        if (!IsPostBack)
        {


            BinData(Id);
            lblimg.Text = "<img src='" + ht + "/" + pathimg + "' >";

        }

    }
    int Id
    {

        get
        {

            return Convert.ToInt32(Request.QueryString["Id"]);

        }

    }
    public string ReadServer()
    {
        string value = "";

        using (XmlTextReader reader = new XmlTextReader(Server.MapPath("config.xml")))
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Text)
                {
                    value = reader.Value;
                }
            }
        }
        return value;
    }


    public void BinData(int eventid)
    {
        DataTable db = data.allSystem("select dbo.tblEventSwim.Id,dbo.tblEventSwim.Date as [Ngay], dbo.tblEventSwim.CardNumber as [mathe], dbo.tblCard.Code as [makh], dbo.tblCard.AccountName as [ten], dbo.tblCardType.Name as [loaithe], dbo.tblEventSwim.PicDir as [anh] from tblEventSwim LEFT JOIN tblCard ON dbo.tblEventSwim.CardNumber=dbo.tblCard.CardNumber LEFT JOIN tblCardType ON dbo.tblCard.CardTypeCode=tblCardType.Code where dbo.tblEventSwim.Id=" + eventid + " ");

        txtname.Text = db.Rows[0]["ten"].ToString();
        txtcatecard.Text = db.Rows[0]["loaithe"].ToString();
        txtdate.Text = db.Rows[0]["Ngay"].ToString();

        string img = db.Rows[0]["anh"].ToString();

        img = img.Substring(12);
        img = img.Replace(@"\", "/");


        pathimg = img;

        // Response.Write("<script>alert(" + img + ")</script>");
        //   lblimg.Text = " <img src='"+img+"' width='520px' height='470px' /> ";
        // lblimg.Text = img;
        //  lblimg.Text = "<img src='" + img + "' width='520px' height='470px' />";
        //  String newName = img.Substring(img.LastIndexOf("\\") + 1, img.Length);

        // lblimg.Text = newName;
        //Response.Write("<script>alert(" + newName + ")</script>");
    }
}